Back to course home
0% completed
Vote For New Content
LinkedIn Hard
Max Points on a Line (hard)
Solution: Max Points on a Line
Closest Binary Search Tree Value II (hard)
Solution: Closest Binary Search Tree Value II
Word Ladder (hard)
Solution: Word Ladder
Median of Two Sorted Arrays (hard)
Solution: Median of Two Sorted Arrays
Largest Rectangle in Histogram (hard)
Solution: Largest Rectangle in Histogram
Serialize and Deserialize Binary Tree (hard)
Solution: Serialize and Deserialize Binary Tree
Decode Ways (medium)
Problem Statement
You have given a string that consists only of digits. This string can be decoded into a set of alphabets where '1' can be represented as 'A', '2' as 'B', ... , '26' as 'Z'. The task is to determine how many ways the given digit string can be decoded into alphabets.
Examples
-
- Input: "121"
- Expected Output: 3
- Justification: The string "121" can be decoded as "ABA", "AU", and "LA".
-
- Input: "27"
- Expected Output: 1
- Justification: The string "27" can only be decoded as "BG".
-
- Input: "110"
- Expected Output: 1
- Justification: The string "110" can only be decoded as "JA".
Constraints:
1 <= s.length <= 100scontains only digits and may contain leading zero(s).
Try it yourself
Try solving this question here:
Java
Saved to Cloud
. . . .
Solution: Longest Substring Without Repeating Characters (medium)
Solution: Decode Ways
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself